package com.lkm.app_ui.jz.util;

import android.annotation.SuppressLint;
import android.content.Context;

import com.lkm.app_ui.MyApplication;


@SuppressLint("CommitPrefEdits")
public class SPUtils {
    public static final String CONFIG = "JZ_CONFIG";

//    private var sp: SharedPreferences = App.context!!.getSharedPreferences(CONFIG, Context.MODE_PRIVATE)

    public static void putString(String key, String value) {
        MyApplication.getInstance()
                .getSharedPreferences(CONFIG, Context.MODE_PRIVATE)
                .edit()
                .putString(key, value)
                .apply();
    }

    public static String getString(String key) {
        return MyApplication.getInstance()
                .getSharedPreferences(CONFIG, Context.MODE_PRIVATE)
                .getString(key, null);
    }

    public static void putInt(String key, int value) {
        MyApplication.getInstance()
                .getSharedPreferences(CONFIG, Context.MODE_PRIVATE)
                .edit()
                .putInt(key, value)
                .apply();
    }

    public static int getInt(String key, int defaultValue) {
        return MyApplication.getInstance()
                .getSharedPreferences(CONFIG, Context.MODE_PRIVATE)
                .getInt(key, defaultValue);
    }
}
